package lion.json.handlers;

import java.io.IOException;
import java.io.Writer;
import java.util.Collection;

import lion.json.IJsonHandler;

/**
 * @author lion
 * @mail hl_0074@sina.com
 * @date 2011-9-27
 */
public class CollectionHandler implements IJsonHandler {

	@Override
	public void handle(Object o, Writer writer) throws IOException {

		if (!(o instanceof Collection)) {
			writer.write("null");
			return;
		}

		Object[] arr = ((Collection<?>) o).toArray();

		new ArrayHandler().handle(arr, writer);
	}

}
